1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to log information management in a database management system, and more particularly, to separately managing information on a data area where a lot of renewals are generated, thereby minimizing repetitively generated log information.
2. Description of the Related Art
A “log” or “logging” in a database management system means that data is stored before being modified in order to prevent the data, being modified by an operation of an application program, from not having a normal value due to a system error or user's carelessness.
The database management system can restore the data, being controlled by an abnormally completed application, to a normal status by the above-described logging.
FIG. 1 illustrates a related art logging system for performing a logging.
Referring to FIG. 1, a related art logging system 100, referred to as a “log manager”, includes a log information input unit 110, a log record generating unit 120, a log request input unit 130, a log buffer managing unit 140 and a log buffer 150.
The related art logging system 100 receives, via the log information input unit 110, information on a data renewal performed in another program module within a system to which the logging system belongs.
The log record generating unit 120 generates a log record by setting required information additionally. The generated log record is recorded in the log buffer 150 via the log buffer managing unit 140. In this case, the log records are recorded in the order in which they were generated.
The log request input unit of the logging system 100 receives a log request message (e.g., transaction completion) by other modules of the system and transmits it to the log buffer managing unit 140. The log buffer managing unit 140 records the log records stored in the log buffer 150 in a log file based on the transmitted log request message.
Based on the log records recorded in the log file and the log buffer 150, data can be safely restored in a case of an abnormal completion of an application or a system error.
The log records maintain at least important information (or data) for restoring the data to an original status. FIG. 2 illustrates a configuration of a related art log record.
Referring to FIG. 2, a log record 200 includes a log sequence number (LSN) field of a previous log record 201, a transaction identifier field 202, a log record type filed 203, a page number filed 204, a page offset field 205, a data length field 206, a previous data image field 207, a new data image field 208, and a LSN field of a log record to-be-invalid 209. Hereinafter, the above information included in the log record 200 is referred to as “log information”.
The LSN field 201 of the previous log record displays numbers for identifying the recorded log record.
The transaction identifier field 202 displays an identifier of a transaction performing a logging.
The log record type field 203, as a field which displays the type of a log record, has different types for each of generated operations such as “renewal”, “transaction start” or “transaction completion”.
The page number field 204 displays the number of a page in which renewed data is stored, when a renewal occurs. The page offset filed 205 displays a start position in the page where the renewed data is stored, when the renewal occurs. The data length field 206 displays a size of the data to be renewed.
The previous data image field 207 displays a previous data value before the renewal is performed and the new data image field 208 displays a modified data value after the renewal is performed.
The LSN field 209 of the log record to-be-invalid displays numbers for identifying the log record to be restored.
A configuration of the log record 200 illustrated in FIG. 2 may be different depending upon a system using the logging, but its basic configuration and meaning are similar.
FIGS. 3A and 3B illustrate a related art process of a logging operation and a transaction cancellation. A configuration of a log record of a log buffer or a log file, illustrated in FIGS. 3A and 3B, is similar to the configuration of the log record illustrated in FIG. 2. The configuration of the log record illustrated in FIGS. 3A and 3B does not include the data length field 206 of the configuration of the log record illustrated in FIG. 2, and the number marked at each log record corresponds to an identification number for identifying each log record.
To perform a logging operation, other modules transmit a before-image and an after-image, as a result of a renewal generated in a transaction, to the log information input unit 110 of the logging system 100.
The log record generating unit 120 generates a log record based on information on the two received data. The log buffer managing unit 140 records the generated log record in the log buffer 150.
All of the generated log records are successively recorded and an LSN value of the recorded log record is allocated in ascending order. The log records recorded in the log buffer 150 are recorded in the log file when the log buffer 150 is full or a “disk writing request” for the log record occurs.
As described above, all of the log records of a renewal generated by other modules are successively recorded. The logging system 100 performs a cancellation by reading the log file when a request to cancel an application program or to restore a system error.
Referring to FIG. 3A, a process of performing a logging operation will be described, which assumes that a transaction T1 performs a renewal of three data pages P1, P2, and P3.
Whenever a renewal is generated for each data page, a corresponding area in the data page is modified to a new value. A first log record displays that “BBB” recorded at 50 bite position in the data page P1 is modified to “AAA”.
Each of the following log records display that a value stored in a specific offset of the corresponding data page is modified to a new value.
Especially, the data recorded at 50 bite of the data page P1 is modified four times. Whenever a modification occurs, a corresponding log record is generated. The logging system 100 generates log records corresponding to all renewals, and records the log records in the log buffer 150 and a log file successively.
FIG. 3 illustrates a process of canceling a transaction. When a renewal illustrated in FIG. 3A occurs, it is assumed that a transaction T1 is not completed normally.
To restore all data that are modified by the transaction T1 into original normal values, all log records of the transaction T1 recorded in the log buffer 150 or the log file are read in reverse order. By doing so, a data value in the corresponding data page is modified into a before-image recorded in each log record. Accordingly, all areas renewed in the corresponding data pages P1, P2, and P3 are restored to previous values before the transaction T1 is performed. In this process, the value at 50 bite of the data page P1 is modified from “EEE” to “BBB” that is the previous value before the four renewals.
As described above, the logging system 100 generates log records and records them successively in the log of all renewals performed by other modules. Accordingly, the logging system 100 repetitively generates new log records of a specific data page where frequent modifications occur by the application or a specific area in the data page. Hereinafter, the data area where a lot of modifications occur is referred to as a “hotspot”.
A hotspot may appear throughout a lot of areas in a system and its size may be greatly various. Accordingly, the number of the log records of the hotspot generated while one operation (transaction) is performed may greatly increase, which may enlarge the log size while the system is operated and a function as a real-time system deteriorates because the log records are continuously generated and page inputs and outputs increase.
In cancellation of an application or system restoration, run-time and restoration functions of the system may deteriorate because all log records generated for the hotspot are used to restore data to an original status.
In the process illustrated in FIG. 3B, for example, the operations with respect to three log records identified as 109, 106, and 103 are unnecessary in order to restore a value at 50 bite of the data page P1.
As various embedded systems such as digital devices are introduced, a safe management of user data stored in the embedded systems is highly required. The data stored in a system may not be maintained as a normal value due to user's carelessness, an abnormal operation of an application program, or a power interruption. Accordingly, a data restoring system to maintain normal data safely is a greatly important system component. However, it is difficult that a logging-based data restoring system ensures a response time and function required in an embedded system in which resources are limited.
Accordingly, it is needed to improve the relate art method of managing log information in the logging-based data restoring system.